/-editor ...
CodeMirrorEditor.ts
CompletionCodeMirrorEditor.ts
CssEditorType.ts
Editor.ts
EditorType.ts
HtmlEditorType.ts
JavaScriptEditorType.ts
TypeScriptEditorType.ts
x-last-PlainTextEditorType.ts
/-files
/-imports
/-layout
/-typings
TypeScriptService.ts
ko.ts
persistence.ts
shell.ts
teapo.html
teapo.js
teapo.ts
205
      var line = doc.getLine(pos.line);
206
 
207
      var leadLength = 0;
208
      var prefixChar = '';
209
      var whitespace = false;
210
      for (var i = pos.ch-1; i >=0; i--) {
211
        var ch = line[i];
212
        if (!whitespace && this._isIdentifierChar(ch)) {
213
          leadLength++;
214
          continue;
215
        }
216
 
217
        whitespace = /\s/.test(ch);
218
        if (!whitespace) {
219
          prefixChar = ch;
220
          break;
221
        }
222
      }
223
 
224
      var tailLength = 0;
225
      var suffixChar = '';
226
      whitespace = false;
227
      for (var i = pos.ch; i <line.length; i++) {
228
        var ch = line[i];
229
        if (!whitespace && this._isIdentifierChar(ch)) {
230
          tailLength++;
231
          continue;
232
        }
233
 
234
        whitespace = /\s/.test(ch);
235
        if (!whitespace) {
236
          suffixChar = ch;
237
          break;
238
        }
239
      }
240
 
241
      return {
242
        pos: pos,
243
        offset: offset,
244
        line: line,
245
        leadLength: leadLength,
246
        prefixChar: prefixChar,
247
        tailLength: tailLength,
248
        suffixChar: suffixChar
249
      };
250
    }
251
 
252
    /** More specifially, number or identifier (numbers, letters, underscore and dollar). */
253
    private _isIdentifierChar(ch: string): boolean {
254
      if (ch.toLowerCase()!==ch.toUpperCase())
255
        return true;
256
      else if (ch==='_' || ch==='$')
257
        return true;
258
      else if (ch>='0' && ch<='9')
259
        return true;
260
      else
261
        return false;
262
    }
263
 
264
 
265
    private _initEditor() {
266
      var options = this._shared.options || CodeMirrorEditor.standardEditorConfiguration();
267
      this._shared.cm = new CodeMirror(
268
        (element) => this._shared.element = element,
269
        options);
270
      this._shared.cm.getWrapperElement().style.fontSize = '16px';
271
    }
272
 
273
    private _initDoc() {
274
 
275
      // resolve options (allow override)
276
      var options = this._shared.options || CodeMirrorEditor.standardEditorConfiguration();
277
      this._doc =
278
        options.mode ? new CodeMirror.Doc('', options.mode) :
279
        new CodeMirror.Doc('');
280
 
281
      this._positionOnOpen = true;
282
 
283
      // invoke overridable handleLoad()